package com.han.verifycode.ver.point;

import com.han.verifycode.CodeConfig;
import com.han.verifycode.data.RightKey;
import com.han.verifycode.enums.VerifyCodeEnum;
import com.han.verifycode.ver.PointAreaMatchCode;
import com.han.verifycode.ver.conf.PicturePuzzleConf;

public class PicturePuzzleCode implements PointAreaMatchCode {
    private PicturePuzzleConf thisConf;
    private VerifyCodeEnum type = VerifyCodeEnum.PicturePuzzle;

    @Override
    public RightKey generate(String code, CodeConfig conf) {
        RightKey key = new RightKey(code);
        if (conf == null) {
            thisConf = new PicturePuzzleConf();
        } else {
            thisConf = (PicturePuzzleConf) conf;
        }
        key.setConfig(thisConf);
        key.setType(type);
        key.setWidth(conf.getWidth());
        key.setHeight(conf.getHeight());
        //tips 为动态 这里需要子类实现

        return key;
    }

    @Override
    public CodeConfig getConfig() {
        return thisConf;
    }
}
